
use clap::Parser;
use wtask_base::{
    error::WResult,
    logs::{LogArgs, log_init},
    machine::runtime_init
};
use wtask_bridge::tcp_proxy;


#[derive(Parser)]
#[command(author, version, about="wTask网桥，可以代理machine，使客户端通过该代理与machine连接", help_template = "\
{before-help}
{about-with-newline}
{usage-heading} {usage}
{all-args}{after-help}

Version: {version}
Author: {author-with-newline}
")]
struct CMDArgs {
    #[arg(long, default_value = "2560")]
    proxy_port: u32,

    #[command(flatten)]
    log_args: LogArgs,
}


fn main() -> WResult<()> {
    let args = CMDArgs::parse();
    log_init(&args.log_args);

    let runtime = runtime_init(1)?;
    runtime.block_on(async {
        tcp_proxy(args.proxy_port).await.unwrap();
    });
    Ok(())
}